//
//  WYBarButton.swift
//  weibo
//
//  Created by 王玉东 on 16/4/8.
//  Copyright © 2016年 wyd. All rights reserved.
//

import UIKit


extension UIBarButtonItem {

     convenience init(title:String? = nil , NImage: String? , target: AnyObject?, action: Selector) {
        
         self.init()
        
        let btn = UIButton(type: UIButtonType.Custom)
        
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        
        btn.setTitle(title, forState: .Normal)
        
        btn.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        
        btn.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        
        if let NImage1 = NImage{
            btn.setImage(UIImage(named: NImage1), forState: .Normal)
            
            btn.setImage(UIImage(named: NImage1 + "_highlighted"), forState: .Highlighted)
        }
        btn.sizeToFit()
        
        customView = btn
    
    }




}
